# 使用Git绝对路径
$gitPath = "C:\Program Files\Git\bin\git.exe"
$projectPath = "d:\MCP"

# 切换到项目目录
Set-Location -Path $projectPath
Write-Host "Changed directory to $projectPath"

# 检查Git状态
& $gitPath status
Write-Host "Initial Git status checked."

# 尝试添加单个文件
& $gitPath add README.md
if ($LASTEXITCODE -eq 0) {
    Write-Host "Successfully added README.md."
} else {
    Write-Host "Failed to add README.md. Error code: $LASTEXITCODE"
}

# 尝试添加所有文件（使用-v参数获取详细输出）
& $gitPath add -v .
if ($LASTEXITCODE -eq 0) {
    Write-Host "Successfully added all files."
} else {
    Write-Host "Failed to add all files. Error code: $LASTEXITCODE"
}

# 检查Git状态
& $gitPath status
Write-Host "Final Git status checked."

# 尝试提交
& $gitPath commit -m "Initial commit"
if ($LASTEXITCODE -eq 0) {
    Write-Host "Files committed successfully."
} else {
    Write-Host "Failed to commit files. Error code: $LASTEXITCODE"
}

pause